package com.itfreer.data.metadata.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.itfreer.form.api.entity.EntityBase;
import com.itfreer.form.api.reflect.DictionaryField;

/**
 * 元数据
 */
@Entity(name = "data_metadata")
@Table(indexes = { @Index(name = "f_d_dn", columnList = "s_mid") })
public class DataMetadataEntity extends EntityBase implements Serializable {

	private static final long serialVersionUID = -7828937287884523173L;

	/**
	 * 外建，元数据ID值
	 */
	@Column(name = "s_mid", nullable = true)
	private String mid;

	/**
	 * 元数据信息ID 主键
	 */
	@Id
	@Column(name = "id", length = 50, nullable = false)
	private String id;

	/**
	 * 排序值
	 */
	@Column(name = "i_order", nullable = true)
	private Integer order;

	/**
	 * 字段名称
	 */
	@Column(name = "s_name", nullable = true)
	private String name;

	/**
	 * 字段别名
	 */
	@Column(name = "s_aliasName", nullable = true)
	private String aliasName;

	/**
	 * 字段类型
	 */
	@Column(name = "s_datatype", nullable = true)
	@DictionaryField(dictionaryName = "f_datatype", toFieldName = "dataTypeName")
	private String dataType;

	/**
	 * 字段类型名称
	 */
	@Transient
	private String dataTypeName;

	/**
	 * 是否是主键
	 */
	@Column(name = "b_key", nullable = true)
	private Boolean key;

	/**
	 * 是否是自动增值列
	 */
	@Column(name = "b_auto", nullable = true)
	private Boolean auto;

	/**
	 * 是否可以为空
	 */
	@Column(name = "b_allowNull", nullable = true)
	private Boolean allowNull;

	/**
	 * 是否可以显示
	 */
	@Column(name = "b_canShow", nullable = true)
	private Boolean canShow;

	/**
	 * 长度
	 */
	@Column(name = "i_maxlen", nullable = true)
	private Integer maxlen;

	/**
	 * 小数位长度
	 */
	@Column(name = "d_decimaldigits", nullable = true)
	private Integer decimaldigits;

	/**
	 * 默认值
	 */
	@Column(name = "s_defaultValue", nullable = true)
	private String defaultValue;

	/**
	 * 字典域
	 */
	@Column(name = "d_dictionaryname", nullable = true)
	@DictionaryField(dictionaryName = "AllSysDic", toFieldName = "dictionaryAliasName")
	private String dictionaryName;

	/**
	 * 字典域
	 */
	@Transient
	private String dictionaryAliasName;

	/**
	 * 字典是否多选
	 */
	@Column(name = "b_dicmultiple", nullable = true)
	private Boolean dictionaryMultiple;

	/**
	 * 显示分组
	 */
	@Column(name = "s_group", nullable = true)
	private String group;

	/**
	 * 对应字典数据的上级id
	 */
	@Column(name = "s_dictionaryDataPid", nullable = true)
	private String dictionaryDataPid;

	/**
	 * 字典加载层级
	 */
	@Column(name = "i_diclevel", nullable = true)
	private Integer dicLevel;

	/**
	 * 标题
	 */
	@Column(name = "b_title", nullable = true)
	private Boolean title;

	/**
	 * 简介
	 */
	@Column(name = "b_simple", nullable = true)
	private Boolean simple;

	/**
	 * 属性
	 */
	@Column(name = "b_attr", nullable = true)
	private Boolean attr;

	/**
	 * 分组
	 */
	@Column(name = "b_split", nullable = true)
	private Boolean split;

	/**
	 * 单位
	 */
	@Column(name = "s_unit", nullable = true)
	private String unit;

	/**
	 * 租户ID
	 */
	@Column(name = "s_tenantID", length = 50, nullable = true)
	private String tenantID;

	/**
	 * 租户名称
	 */
	@Column(name = "s_tenantName", length = 50, nullable = true)
	private String tenantName;

	/**
	 * 共享租户ID
	 */
	@Column(name = "s_shareTenantID", nullable = true, columnDefinition = "text")
	private String shareTenantID;

	public void setMid(String mid) {
		this.mid = mid;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setOrder(Integer order) {
		this.order = order;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setAliasName(String aliasName) {
		this.aliasName = aliasName;
	}

	public void setDataType(String dataType) {
		this.dataType = dataType;
	}

	@Transient
	public String getDataTypeName() {
		return dataTypeName;
	}

	public void setDataTypeName(String dataTypeName) {
		this.dataTypeName = dataTypeName;
	}

	public void setKey(Boolean isKey) {
		this.key = isKey;
	}

	public void setAuto(Boolean isAuto) {
		this.auto = isAuto;
	}

	public void setAllowNull(Boolean allowNull) {
		this.allowNull = allowNull;
	}

	public void setMaxlen(Integer maxlen) {
		this.maxlen = maxlen;
	}

	public void setDecimaldigits(Integer decimaldigits) {
		this.decimaldigits = decimaldigits;
	}

	public void setDefaultValue(String defaultValue) {
		this.defaultValue = defaultValue;
	}

	public void setDictionaryName(String dictionaryName) {
		this.dictionaryName = dictionaryName;
	}

	public void setCanShow(Boolean canShow) {
		this.canShow = canShow;
	}

	/**
	 * 租户ID
	 */
	public void setTenantID(String tenantID) {
		this.tenantID = tenantID;
	}

	/**
	 * 租户名称
	 */
	public void setTenantName(String tenantName) {
		this.tenantName = tenantName;
	}

	/**
	 * 外建，元数据ID值
	 */
	public String getMid() {
		return mid;
	}

	/**
	 * 元数据信息ID 主键
	 */
	public String getId() {
		return id;
	}

	/**
	 * 排序值
	 */
	public Integer getOrder() {
		return order;
	}

	/**
	 * 字段名称
	 */
	public String getName() {
		return name;
	}

	/**
	 * 字段别名
	 */
	public String getAliasName() {
		return aliasName;
	}

	/**
	 * 字段类型
	 */
	public String getDataType() {
		return dataType;
	}

	/**
	 * 是否是主键
	 */
	public Boolean getKey() {
		return key;
	}

	/**
	 * 是否是自动增值列
	 */
	public Boolean getAuto() {
		return auto;
	}

	/**
	 * 是否可以为空
	 */
	public Boolean getAllowNull() {
		return allowNull;
	}

	/**
	 * 是否可以显示
	 */
	public Boolean getCanShow() {
		return canShow;
	}

	/**
	 * 长度
	 */
	public Integer getMaxlen() {
		return maxlen;
	}

	/**
	 * 小数位长度
	 */
	public Integer getDecimaldigits() {
		return decimaldigits;
	}

	/**
	 * 默认值
	 */
	public String getDefaultValue() {
		return defaultValue;
	}

	/**
	 * 字典域
	 */
	public String getDictionaryName() {
		return dictionaryName;
	}

	@Transient
	public String getDictionaryAliasName() {
		return dictionaryAliasName;
	}

	public void setDictionaryAliasName(String dictionaryAliasName) {
		this.dictionaryAliasName = dictionaryAliasName;
	}

	public Boolean getDictionaryMultiple() {
		return dictionaryMultiple;
	}

	public void setDictionaryMultiple(Boolean dictionaryMultiple) {
		this.dictionaryMultiple = dictionaryMultiple;
	}

	/**
	 * 分组
	 */
	public String getGroup() {
		return group;
	}

	/**
	 * 分组
	 */
	public void setGroup(String group) {
		this.group = group;
	}

	/**
	 * 对应字典数据的上级id
	 */
	public String getDictionaryDataPid() {
		return dictionaryDataPid;
	}

	/**
	 * 对应字典数据的上级id
	 */
	public void setDictionaryDataPid(String dictionaryDataPid) {
		this.dictionaryDataPid = dictionaryDataPid;
	}

	public Integer getDicLevel() {
		return dicLevel;
	}

	public void setDicLevel(Integer dicLevel) {
		this.dicLevel = dicLevel;
	}

	public Boolean getTitle() {
		return title;
	}

	public void setTitle(Boolean title) {
		this.title = title;
	}

	public Boolean getSimple() {
		return simple;
	}

	public void setSimple(Boolean simple) {
		this.simple = simple;
	}

	public Boolean getAttr() {
		return attr;
	}

	public void setAttr(Boolean attr) {
		this.attr = attr;
	}

	public Boolean getSplit() {
		return split;
	}

	public void setSplit(Boolean split) {
		this.split = split;
	}

	public String getUnit() {
		return unit;
	}

	public void setUnit(String unit) {
		this.unit = unit;
	}

	/**
	 * 租户ID
	 */
	public String getTenantID() {
		return tenantID;
	}

	/**
	 * 租户名称
	 */
	public String getTenantName() {
		return tenantName;
	}

	@Override
	public String getShareTenantID() {
		return shareTenantID;
	}

	@Override
	public void setShareTenantID(String shareTenantID) {
		this.shareTenantID = shareTenantID;
	}
}
